import { http } from '@/utils/http'
import type {
  IOrder,
  IOrderPageParam,
  IOrderCreateOk,
  WxPayJsapiParams,
  IOrderStatusParam,
  IOrderItem,
  IUnifiedOrderParams,
  ApplyRefundParam,
  ExpectOrderForm,
  IexpectOrderVo,
} from '@/types/order'
import type { PageData } from '@/types/global'

import type { IcartItem } from '@/types/cart'

/**
 * 填写订单-获取预付订单
 */
export const createOrderAPI = (data: IOrder) => {
  return http<IOrderCreateOk>({
    method: 'POST',
    url: '/sys/app/orders/create',
    data,
  })
}
export const applyRefundAPI = (data: ApplyRefundParam) => {
  return http<string>({
    method: 'POST',
    url: '/sys/app/orders/applyRefund',
    data,
  })
}
export const unifiedorderAPI = (data: IUnifiedOrderParams) => {
  return http<WxPayJsapiParams>({
    method: 'POST',
    url: '/sys/app/orders/test/unifiedorder',
    data,
  })
}

export const pageOrderAPI = (data: IOrderPageParam) => {
  return http<PageData<IOrder[]>>({
    method: 'POST',
    url: '/sys/app/orders/appPage',
    data,
  })
}

export const expectOrderAPI = (data: ExpectOrderForm) => {
  return http<IexpectOrderVo>({
    method: 'POST',
    url: '/sys/app/driverorders/expectOrder',
    data,
  })
}
export const pageOrderStatusAPI = (data: IOrderStatusParam) => {
  return http<string>({
    method: 'POST',
    url: '/sys/app/orders/orderStatus',
    data,
  })
}
export const cancelOrderAPI = (data: any) => {
  return http<string>({
    method: 'POST',
    url: '/sys/app/orders/cancelOrder',
    data,
  })
}
export const aginDetailAPI = (data: any) => {
  return http<IcartItem[]>({
    method: 'GET',
    url: '/sys/app/orders/aginDetail',
    data,
  })
}
